package lab02.test30;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        //从键盘读取一个考试分数列表，计算它们的平均分
        double markin;
        double average=0.0;
        Scanner scanner=new Scanner(System.in);
        List<Double> marks=new ArrayList<Double>();
   do {
       System.out.println("输入学生成绩,输入负数时结束：");
       markin=scanner.nextDouble();
       marks.add(markin);

   }
   while (markin>=0);
   int length=marks.size()-1;
   marks.remove(length);
   for (int i=0;i<length;i++){
       average+=marks.get(i)/length;

   }
        System.out.println(length+"名学生的平均成绩为："+average);
    }
}
